import org.junit.Test;
import test.ListNode;

/**
 * 5  给你一个俩你报的节点,head,请你判断该链表是否为会问链表
 */
public class isPalindrome {

    @Test
    public void clibe() {
        ListNode list1 = new ListNode(1, new ListNode(2));
        System.out.println(test1(list1));
    }

    public boolean test1(ListNode head) {
        ListNode fast = head, slow = head;
        while (fast != null && fast.getNext() != null) {
            fast = fast.getNext().getNext();
            slow = slow.getNext();
        }
        if (fast != null) {
            slow = slow.getNext();
        }
        reverseList reverseList = new reverseList();
        slow = reverseList.test1(slow);
        fast = head;
        while (slow != null) {
            if (fast.getVal() != slow.getVal()) {
                return false;
            }
            fast = fast.getNext();
            slow = slow.getNext();
        }
        return true;
    }
}
